<script setup>
name: 'rights'
import { ref, onMounted } from 'vue'
import { getRightsListAPI } from '@/api/authorityAPI'
import { ElMessage } from 'element-plus';

// 获取权限列表
const rightsList = ref([])
const getRightsList = async (type) => {
    const { data: res } = await getRightsListAPI(type)
    if (res.meta.status !== 200) return ElMessage.error(res.meta.msg)
    rightsList.value = res.data
}

onMounted(() => {
    getRightsList('list')
})

</script>

<template>
    <!-- 面包屑导航 -->
    <el-breadcrumb separator=">">
        <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
        <el-breadcrumb-item>权限管理</el-breadcrumb-item>
        <el-breadcrumb-item>权限列表</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 卡片视图 -->
    <el-card>
        <el-table :data="rightsList" style="width: 100%" stripe border>
            <el-table-column type="index" label="#"></el-table-column>
            <el-table-column prop="authName" label="权限名称" />
            <el-table-column prop="path" label="路径" />
            <el-table-column label="权限等级">
                <template v-slot="scope">
                    <el-tag size="large" v-if="scope.row.level === '0'">一级</el-tag>
                    <el-tag size="large" type="success" v-if="scope.row.level === '1'">二级</el-tag>
                    <el-tag size="large" type="warning" v-if="scope.row.level === '2'">三级</el-tag>
                </template>
            </el-table-column>
        </el-table>
    </el-card>
</template>

<style scoped></style>